package edu.usm.predatorwars.webservice;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import edu.predatorwars.shared.models.Message;
import edu.usm.predatorwars.GameEventConsumer;

/**
 * Exposes a resource (web service) that will be called by game host
 */
@Path("/predatorwars/client")
@Consumes(MediaType.APPLICATION_JSON)
public class ClientMaskResource {

	private final GameEventConsumer consumer;

	public ClientMaskResource(GameEventConsumer consumer) {
		this.consumer = consumer;
	}
	
	@Path("/message")
	@POST @Produces(MediaType.APPLICATION_JSON)
	public Response onMessage(Message message) {
		consumer.addMessage(message);
		return Response.ok().build();
	}
}
